package com.cdd.statistics.controller;


import com.cdd.commonutils.R;
import com.cdd.statistics.client.UcenterClient;
import com.cdd.statistics.entity.StatisticsDaily;
import com.cdd.statistics.service.StatisticsDailyService;
import org.apache.commons.lang3.RandomUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 * 网站统计日数据 前端控制器
 * </p>
 *
 * @author cdd
 * @since 2021-02-16
 */
@RestController
@RequestMapping("/statistics/statistics-daily")
@CrossOrigin
public class StatisticsDailyController {

    @Autowired
    private StatisticsDailyService statisticsDailyService;

    // 统计某一天注册人数
    @PostMapping("registerCount/{day}")
    public R registerCount(@PathVariable String day){
        statisticsDailyService.countRegister(day);
        return R.ok();
    }

    // 图表显示，返回两部分数据，日期json，数量json
    @GetMapping("show-chart/{begin}/{end}/{type}")
    public R showChart(@PathVariable String begin,@PathVariable String end,@PathVariable String type){
        Map<String, Object> map = statisticsDailyService.getChartData(begin, end, type);
        return R.ok().data(map);
    }

}

